<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="cn.com.xf.common.Constants"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	List<TblApiApp> list = (List<TblApiApp>)request.getAttribute("list");
	AppForm form = (AppForm)request.getAttribute("command");
	String companyName = StringUtils.isNotBlank(form.getCompanyName())?form.getCompanyName():"";
	String appType = StringUtils.isNotBlank(form.getAppType())?form.getAppType():"";
	String appStatus = StringUtils.isNotBlank(form.getAppStatus())?form.getAppStatus():"";
%>

<div class="userListWrap">

     <form id="userListForm">
        <div class="form-item">
    		<label for="deviceid">厂商名称:</label>
    		<input class="easyui-validatebox" type="text" name="companyName" data-options="" value="<%=companyName%>"/>
        </div>
        <div class="form-item form-item">
    		<a href="javascript:XF.APP.listAPPSearch()" class="input-btn-microsoft input-btn-microsoft-24">搜索</a>
        </div>
    </form>

    <table id="barListTable" class="easyui-datagrid"  title="" >
        <thead>
    		<tr>
    			<th data-options="field:'deviceid',width:100" orderByField='companyName' >
					<a class="order-field" href="javascript:XF.APP.listAPPSearch('companyName')" >厂商名称</a>
					<%
						if(StringUtils.isNotBlank(form.getOrderByField()) && StringUtils.isNotBlank(form.getOrderByMode())){
							if("companyName".equalsIgnoreCase(form.getOrderByField())){
								if("asc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px t" orderByMode='desc'>&nbsp;</span><%
								}else if("desc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px d" orderByMode='asc'>&nbsp;</span><%
								}else{
									%><span class="px" orderByMode='asc'>&nbsp;</span><%
								}
							}else{
								%><span class="px" orderByMode='asc'>&nbsp;</span><%
							}
						}else{
							%><span class="px" orderByMode='asc'>&nbsp;</span><%
						}
					%>
				</th>
    			<th data-options="field:'siteid',width:100" orderByField='appOS' >
					<a class="order-field" href="javascript:XF.APP.listAPPSearch('appOS')" >操作系统</a>
					<%
						if(StringUtils.isNotBlank(form.getOrderByField()) && StringUtils.isNotBlank(form.getOrderByMode())){
							if("appOS".equalsIgnoreCase(form.getOrderByField())){
								if("asc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px t" orderByMode='desc'>&nbsp;</span><%
								}else if("desc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px d" orderByMode='asc'>&nbsp;</span><%
								}else{
									%><span class="px" orderByMode='asc'>&nbsp;</span><%
								}
							}else{
								%><span class="px" orderByMode='asc'>&nbsp;</span><%
							}
						}else{
							%><span class="px" orderByMode='asc'>&nbsp;</span><%
						}
					%>
				</th>
    			<th data-options="field:'appVersion',width:100" orderByField='appVersion' >
					<a class="order-field" href="javascript:XF.APP.listAPPSearch('appVersion')" >版本号</a>
					<%
						if(StringUtils.isNotBlank(form.getOrderByField()) && StringUtils.isNotBlank(form.getOrderByMode())){
							if("appVersion".equalsIgnoreCase(form.getOrderByField())){
								if("asc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px t" orderByMode='desc'>&nbsp;</span><%
								}else if("desc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px d" orderByMode='asc'>&nbsp;</span><%
								}else{
									%><span class="px" orderByMode='asc'>&nbsp;</span><%
								}
							}else{
								%><span class="px" orderByMode='asc'>&nbsp;</span><%
							}
						}else{
							%><span class="px" orderByMode='asc'>&nbsp;</span><%
						}
					%>
				</th>
				<th data-options="field:'appType',width:100" orderByField='appType' >
					<a class="order-field" href="javascript:XF.APP.listAPPSearch('appType')" >应用类型</a>
					<%
						if(StringUtils.isNotBlank(form.getOrderByField()) && StringUtils.isNotBlank(form.getOrderByMode())){
							if("appType".equalsIgnoreCase(form.getOrderByField())){
								if("asc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px t" orderByMode='desc'>&nbsp;</span><%
								}else if("desc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px d" orderByMode='asc'>&nbsp;</span><%
								}else{
									%><span class="px" orderByMode='asc'>&nbsp;</span><%
								}
							}else{
								%><span class="px" orderByMode='asc'>&nbsp;</span><%
							}
						}else{
							%><span class="px" orderByMode='asc'>&nbsp;</span><%
						}
					%>
				</th>
				<th data-options="field:'appStatus',width:100" orderByField='appStatus' >
					<a class="order-field" href="javascript:XF.APP.listAPPSearch('appStatus')" >使用状态</a>
					<%
						if(StringUtils.isNotBlank(form.getOrderByField()) && StringUtils.isNotBlank(form.getOrderByMode())){
							if("appStatus".equalsIgnoreCase(form.getOrderByField())){
								if("asc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px t" orderByMode='desc'>&nbsp;</span><%
								}else if("desc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px d" orderByMode='asc'>&nbsp;</span><%
								}else{
									%><span class="px" orderByMode='asc'>&nbsp;</span><%
								}
							}else{
								%><span class="px" orderByMode='asc'>&nbsp;</span><%
							}
						}else{
							%><span class="px" orderByMode='asc'>&nbsp;</span><%
						}
					%>
				</th>
    			
    			
 				<th data-options="field:'addTime',width:140" orderByField='addTime' >
					<a class="order-field" href="javascript:XF.Bar.listBarSearch('addTime')" >添加时间</a>
					<%
						if(StringUtils.isNotBlank(form.getOrderByField()) && StringUtils.isNotBlank(form.getOrderByMode())){
							if("addTime".equalsIgnoreCase(form.getOrderByField())){
								if("asc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px t" orderByMode='desc'>&nbsp;</span><%
								}else if("desc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px d" orderByMode='asc'>&nbsp;</span><%
								}else{
									%><span class="px" orderByMode='asc'>&nbsp;</span><%
								}
							}else{
								%><span class="px" orderByMode='asc'>&nbsp;</span><%
							}
						}else{
							%><span class="px" orderByMode='asc'>&nbsp;</span><%
						}
					%>
				</th>
				<th data-options="field:'opr',width:100">操作</th>
    		</tr>
        </thead>
        <tbody>
        	<%
        		if(!CollectionUtils.isEmpty(list)){
        			for(TblApiApp app:list){
        				%>
       					 <tr s="<%=EncrypTool.encode(app.getId()+"") %>">
							<td><i s="<%=EncrypTool.encode(app.getId()+"")%>"></i><%=(null!=app.getCompany())?app.getCompany()+"":"" %></td>
       					 	<td><%=(null!=app.getAppOs())? Constants.APP_OS_TYPE_MAP.get( app.getAppOs())+"":"" %></td>
       					 	<td><%=StringUtils.isNotBlank(app.getAppVersion())?app.getAppVersion():"" %></td>
       					 	<td><%=StringUtils.isNotBlank(app.getType())? Constants.APP_TYPE_MAP.get(app.getType().trim()):"" %></td>
       					 	
       					 	<td><%=StringUtils.isNotBlank(app.getStatus())?Constants.APP_STATUS_MAP.get(app.getStatus().trim()):"" %></td>
       					 	<td><%=null!=app.getAddTime()?DateFormatUtils.format(app.getAddTime().getTime(), "yyyy-MM-dd HH:mm:ss"):"" %></td>
			    			
			    			<sec:authorize ifAnyGranted="MANAGE_BAR_APP,MANAGE_BAR">
				    			<td>
									<sec:authorize ifAllGranted="MANAGE_BAR_APP">
										<a href="javascript:XF.APP.deleteApp('<%=EncrypTool.encode(app.getId()+"")%>')"><span>删除</span></a>
										<a href="javascript:XF.APP.modifyApp('<%=EncrypTool.encode(app.getId()+"")%>')"><span>修改</span></a>
									</sec:authorize>
				    			</td>
			    			</sec:authorize>
			    		</tr>
        				<%
        			}
        		}
        	%>
    	</tbody>
    </table>
    <div class="pagination paginationFixWidth">
		<monggoTag:pagination 
		href="app_search"
		pageSize="<%=form.getPageSize()%>" 
		totalRecord="<%=form.getTotalRecord() %>" 
		currentPage="<%=form.getPageNum() %>">
		</monggoTag:pagination> 
	</div>
</div>
<script>
	$('#barListTable').datagrid();  
</script>





























